home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!news
- From: jlilley@ix.netcom.com (John Lilley)
- Newsgroups: comp.lang.c++
- Subject: Re: overloading and ellipsis
- Date: 29 Mar 1996 17:16:34 GMT
- Organization: Netcom
- Message-ID: <4jh5ti$scq@dfw-ixnews6.ix.netcom.com>
- References: <tuka05p3gq.fsf@twit.informatik.uni-bremen.de>
- NNTP-Posting-Host: den-co11-03.ix.netcom.com
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=US-ASCII
- X-NETCOM-Date: Fri Mar 29 11:16:34 AM CST 1996
- X-Newsreader: WinVN 0.99.7
-
- In article <tuka05p3gq.fsf@twit.informatik.uni-bremen.de>,
- thuerman@informatik.uni-bremen.de says...
- >
- >I'd like to overload a function with ellipsis but g++ doesn't let me
- >do that. Should that be possible?
-
- >void send(char *fmt, ...);
- >void send(char *s);
- >
- >main()
- >{
- > send("abc\n"); // error: ambiguous
- >}
- >
- >But nevertheless I would think that the third function matches better
- >than the first, so there would be exactly one best match and the call legal.
- >Does the ARM say something about this, and is g++ correct?
-
- When the candidates for overload resolution are compared, they
- are all compared *as if* they had the same number of arguments.
- This means that:
- void f(char*);
- void f(char*, int x=1);
- void f(char*, ...);
- When matched against the call to
- f("string");
-
- Are all evaluated as if they had one parameter of type char*.
- There is no comparison of "default", or "ellipsis" parameters
- that are unspecified in the function call, and so all are
- equivalent candidates.
-
- Therefore, there is no "ellipsis match" to compare, and the
- call is ambiguous.
-
- john lilley
-
-